package com.youbang.settings.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.youbang.settings.model.SettingEntity;
import com.youbang.settings.model.ThemeEntity;
import com.youbang.settings.service.SettingService;

@Controller
@RequestMapping("/setting")
public class SettingController {
	@Autowired
	private SettingService settingservice;
	@RequestMapping("/editSettings")
	public String settingFn() {
		return "settings/setting";
		
	}
	@RequestMapping(value = "/SaveSettings",method = RequestMethod.POST)
	public String saveSettings(SettingEntity setting) {
		settingservice.updateByPrimaryKey(setting);
		return "settings/setting";
	}
	@RequestMapping(value = "/GetThemeList",method = RequestMethod.GET)
	@ResponseBody
	public List<ThemeEntity> getThemeList(Model model) {
		
		return settingservice.queryList();
	}
	@RequestMapping(value = "/GetCurrentTheme",method = RequestMethod.POST)
	@ResponseBody
	public ThemeEntity getCurrentTheme(int id) {
		return settingservice.queryEntity(id);
	}
	
}
